package action.gsgl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.util.Component;
import com.util.Util;
import com.syslog.SysLogServices;
import services.gsgl.KTgsServices;
/**
 * 口头挂失
 * @author host
 *
 */
@Controller
@RequestMapping("ktgs.do")
public class KTgsAction {	
	KTgsServices ss = new  KTgsServices();
	SysLogServices log = SysLogServices.getInstance();	
	/**
	 * 性别下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getaac004")
	public void getSelectaac004(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("lx", request));
		Component.print(Util.Encode(data), response);
	}		
	/**
	 * 民族下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getaac005")
	public void getSelectaac005(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getSelect(Component.getQuest("lx", request));
		Component.print(Util.Encode(data), response);
	}		
	/**
	 * 查询单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=checkdata")
	public void checkdata(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String aac001 = Component.getQuest("aac001", request);
		String aaz514 = Component.getQuest("aaz514", request);
		String aae011 = Component.getSession("userid", request);
		HashMap row = new HashMap();
		HashMap obj = new HashMap();
		row.put("aac001", aac001);
		row.put("aaz514", aaz514);
		String msg = ss.checkdata(row);
		if(!msg.equals("0")) {								
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息校验，社会保障卡号：" + aac001 + "变更类型:" + aaz514);
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + aac001 + "变更类型:" + aaz514); //输入参数
			obj.put("dataout", "error");//输出参数
			log.sysLogMap(obj, request);
		}
		else {								
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息校验：社会保障卡号" + aac001 + "变更类型:" + aaz514);
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + aac001 + "变更类型:" + aaz514); //输入参数
			obj.put("dataout", "success");//输出参数
			log.sysLogMap(obj, request);
		}
		Component.print(Util.Encode(msg), response);
	}		
	/**
	 * 获取单位登记信息
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getdata")
	public void getdata(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String aac001 = Component.getQuest("aac001", request);	
		String aae011 = Component.getSession("userid", request);
		HashMap map = ss.getdata(aac001);
		HashMap obj = new HashMap();
		if(null== map) {								
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息查询，社会保障卡号：" + aac001);
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + aac001); //输入参数
			obj.put("dataout", "error");//输出参数
			log.sysLogMap(obj, request);
		}
		else {								
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T05");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息查询，社会保障卡号" + aac001);
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + aac001); //输入参数
			obj.put("dataout", "success");//输出参数
			log.sysLogMap(obj, request);
		}
		map.put("aae011", aae011);
		Component.print(Util.Encode(map), response);
	}		
	/**
	 * 银行下拉框选项
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params = "method=getyinhang")
	public void getYinhang(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List data = ss.getYinhang(Component.getQuest("sj", request));
		Component.print(Util.Encode(data), response);
	}		
	/**
	 * 校验导入
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(params ="method=savedata")
	public void savedata(HttpServletRequest request, HttpServletResponse response) throws Exception {		
		String json = request.getParameter("data");
		String aae011 = Component.getSession("userid", request);
		ArrayList rows = (ArrayList)Util.Decode(json);		
		HashMap row = (HashMap)rows.get(0);	
		row.put("aae011", aae011);
		String datareturn = ss.savedata(row);	
		HashMap obj = new HashMap();
		if(!datareturn.equals("0")) {		
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T02");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息登记，社会保障卡号：" + row.get("aac001") + "变更类型:" + row.get("aaz514"));
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + row.get("aac001") + "变更类型:" + row.get("aaz514")); //输入参数
			obj.put("dataout", "error");//输出参数
			log.sysLogMap(obj, request);
		}
		else {		
			obj.put("domainid", "SBK");  //分系统号，见sys_log_bm
			obj.put("log_type", "T02");   //日志类别，见sys_log_bm
			obj.put("userid", aae011); //操作人
			obj.put("rwh", Component.getSession("rwid", request));	//任务号（菜单号），取Component.getSession("rwid", request),若特殊则为空为自定义
			obj.put("content", "口头挂失信息登记，社会保障卡号：" + row.get("aac001") + "变更类型:" + row.get("aaz514"));
			obj.put("czqd", "Q1");	      //操作渠道，见sys_log_bm
			obj.put("czrlb", "L01");      //操作人类别，见sys_log_bm
			obj.put("datain", "社会保障卡号：" + row.get("aac001") + "变更类型:" + row.get("aaz514")); //输入参数
			obj.put("dataout", "success");//输出参数
			log.sysLogMap(obj, request);
		}
	    Component.print(Util.Encode(datareturn), response);
	} 
}
